package zjut.cocouml.editpolicy;

import java.util.Map;

import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.AbstractEditPolicy;

import zjut.cocouml.command.BClassModifyCommand;

public class ModifyClassPolicy extends AbstractEditPolicy {

	public Command getCommand(Request request) {
		if (request.getType().equals("modifyClass")) {
			return createModifyClassCommand(request);
		}
		return null;
	}
	
	protected Command createModifyClassCommand(Request request) {
		BClassModifyCommand command = new BClassModifyCommand();
		command.setModel(getHost().getModel());
		
		System.out.println("ModifyClassPolicy...createModifyClassCommand");
		Map map = request.getExtendedData();
		command.setNewClassName((String)map.get("newName"));
		command.setNewAccessAuthrity((String)map.get("accessAuthrity"));
		command.setNewIsFinal((Boolean)map.get("isFinal"));
		command.setNewIsAbstract((Boolean)map.get("isAbstract"));

		return command;
	}
}
